import { toData, toDataForSys } from "@/appBase/utils";
import { http, httpDel, httpGet, httpPost } from '@/appBase/request';

/**
 * 登录
 * @param {Object} parmas
 * @param {String} parmas.code 
 * @param {String} parmas.password 
 * @param {String} parmas.username 
 * @param {String} parmas.uuid 
 */
export function login(parmas) {
    return httpPost('/login',parmas).then((result) => toDataForSys(result));
}

export function getInfo() {
    // const result = {"msg":"操作成功","code":200,"permissions":["*:*:*"],"roles":["admin"],"user":{"searchValue":null,"createBy":"admin","createTime":"2022-01-23 22:31:56","updateBy":null,"updateTime":null,"remark":"管理员","params":{},"userId":"1","deptId":"102","userName":"admin","nickName":"admin","email":"","phonenumber":"","sex":"0","avatar":"","salt":null,"status":"0","delFlag":"0","loginIp":"27.10.12.128","loginDate":"2022-11-20 15:38:07","dept":{"searchValue":null,"createBy":null,"createTime":null,"updateBy":null,"updateTime":null,"remark":null,"params":{},"deptId":"102","parentId":"100","ancestors":null,"deptName":"总工办","orderNum":"2","leader":"","phone":null,"email":null,"status":"0","delFlag":null,"parentName":null,"deptLeaderId":null,"firstDeptId":null,"areaName":null,"children":[]},"roles":[{"searchValue":null,"createBy":null,"createTime":null,"updateBy":null,"updateTime":null,"remark":null,"params":{},"roleId":"2","roleName":"职员","roleKey":"R-Common","roleSort":"2","dataScope":"4","menuCheckStrictly":false,"deptCheckStrictly":false,"status":"0","delFlag":null,"flag":false,"menuIds":null,"deptIds":null,"admin":false}],"roleIds":null,"postIds":null,"roleId":null,"directLeaderId":"0","admin":true}}
    return httpGet('/getInfo').then((result) =>  toDataForSys(result));
    // return Promise.resolve(toData({"msg":"操作成功","code":200,"permissions":["*:*:*"],"roles":["admin"],"user":{"searchValue":null,"createBy":"admin","createTime":"2021-09-26 09:33:11","updateBy":null,"updateTime":null,"remark":"管理员","params":{},"userId":"1","deptId":"103","userName":"admin","nickName":"管理员","email":"15123123@163.com","phonenumber":"15888888888","sex":"1","avatar":"","salt":null,"status":"0","delFlag":"0","loginIp":"183.230.166.96","loginDate":"2021-11-15T07:54:03.002+00:00","dept":{"searchValue":null,"createBy":null,"createTime":null,"updateBy":null,"updateTime":null,"remark":null,"params":{},"deptId":"103","parentId":"101","ancestors":null,"deptName":"项目部","orderNum":"1","leader":"若依1","phone":null,"email":null,"status":"0","delFlag":null,"parentName":null,"children":[]},"roles":[{"searchValue":null,"createBy":null,"createTime":null,"updateBy":null,"updateTime":null,"remark":null,"params":{},"roleId":"1","roleName":"超级管理员","roleKey":"admin","roleSort":"1","dataScope":"1","menuCheckStrictly":false,"deptCheckStrictly":false,"status":"0","delFlag":null,"flag":false,"menuIds":null,"deptIds":null,"admin":true}],"roleIds":null,"postIds":null,"roleId":null,"admin":true}}));
}

export function postLogout() {
    return httpDel('/logout').then((result) => toDataForSys(result));
}

// 获取验证码
export function getCodeImg() {
    return httpGet('/captchaImage').then((result) => toDataForSys(result));
}
